package com.hankol.community.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.baselibrary.BaseConstant;
import com.baselibrary.router.ActivityRouter;
import com.baselibrary.utils.ARouterUtils;
import com.baselibrary.adapter.LineBreakTagAdapter;
import com.hankol.community.R;
import com.baselibrary.bean.TimelineInfoData;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author 关忆北丶
 * @description:
 * @date :2020/11/18 18:51
 */
public class TextLineBreakAdapter extends LineBreakTagAdapter {
    private List<TimelineInfoData.AtMembersBean> mList = new ArrayList<>();
    private LayoutInflater mInflater;
    private Activity mAct;

    public TextLineBreakAdapter(List<TimelineInfoData.AtMembersBean> mList, LayoutInflater mInflater, Activity mAct) {
        this.mList = mList;
        this.mInflater = mInflater;
        this.mAct = mAct;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position) {
        View inflate = mInflater.inflate(R.layout.item_text_linebreak, null);

        TextView textView = inflate.findViewById(R.id.tv_linebreak);
        textView.setText("@" + mList.get(position).getName());
        textView.setOnClickListener(v -> {
            HashMap<String, Object> hashMap = new HashMap<>();
            hashMap.put(BaseConstant.USER_ID, String.valueOf(mList.get(position).getId()));
            ARouterUtils.jump(ActivityRouter.MINE_CENTER.USER_INFO, hashMap);

        });
        return inflate;
    }
}
